﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Peak.Core;
using Peak.Core.DataInterfaces;
using SharpArch.Core.PersistenceSupport;

namespace Peak.ApplicationServices
{
  class TaskService : ITaskService
  {
    private readonly IRepository<Task> _taskRepository;
    private readonly IStoryService _storyService;

    public TaskService(IRepository<Task> taskRepository, IStoryService storyService)
    {
      _taskRepository = taskRepository;
      _storyService = storyService;
    }

    public void Add(Task task)
    {
      _taskRepository.SaveOrUpdate(task);
      task.Story.RemainingEffort += task.RemainingEffort;
      task.EstimatedEffort += task.EstimatedEffort;
      _storyService.Update(task.Story);
    }
  }
}
